﻿using System;
using System.Collections.Generic;

namespace Carbon.Web.Forms
{
    public class UpdateControlEventArgs : EventArgs
    {
        #region Fields (3)
        private UpdateControlStageEnum m_Stage = default(UpdateControlStageEnum);

        private bool m_UpdateChildrenViewControls = true;

        private ICollection<EventHandler<ChildViewControlPreUpdateEventArgs>> m_HandlersStack;
        #endregion

        #region Events (1)
        public event EventHandler<ChildViewControlPreUpdateEventArgs> PreUpdateChildViewControl
        {
            add
            {
                m_HandlersStack.Add(value);
            }
            remove
            {
                m_HandlersStack.Remove(value);
            }
        }
        
        private EventHandler<ControlDescendantsUpdatedEventArgs> m_ControlDescendantsUpdated = default(EventHandler<ControlDescendantsUpdatedEventArgs>);
        public EventHandler<ControlDescendantsUpdatedEventArgs> ControlDescendantsUpdated
        {
            get
            {
                return m_ControlDescendantsUpdated;
            }
            set
            {
                m_ControlDescendantsUpdated = value;
            }
        } 
        #endregion

        #region Properties (2)
        public UpdateControlStageEnum Stage
        {
            get
            {
                return m_Stage;
            }
        }
        public bool UpdateChildrenViewControls
        {
            get
            {
                return m_UpdateChildrenViewControls;
            }
            set
            {
                m_UpdateChildrenViewControls = value;
            }
        }
        #endregion

        #region Constructors (1)
        public UpdateControlEventArgs(UpdateControlStageEnum stage, ICollection<EventHandler<ChildViewControlPreUpdateEventArgs>> handlersStack)
            : base()
        {
            if (handlersStack == null) throw new NullReferenceException("handlers");
            this.m_Stage = stage;
            m_HandlersStack = handlersStack;
        }
        #endregion
    }
}
